home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.4 Applications 1997 August / SGI IRIX 6.4 Applications 1997 August.iso / dist / gateway.idb / usr / WebFace / Apps / sdr.cgi.z / sdr.cgi
Encoding:
Text File  |  1997-07-30  |  24.1 KB  |  755 lines

  1. #!/usr/bin/perl5
  2. #
  3. # sdr.cgi
  4. #
  5. # Copyright 1988-1996 Silicon Graphics, Inc.
  6. # All rights reserved.
  7. #
  8. # This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  9. # the contents of this file may not be disclosed to third parties, copied or
  10. # duplicated in any form, in whole or in part, without the prior written
  11. # permission of Silicon Graphics, Inc.
  12. #
  13. # RESTRICTED RIGHTS LEGEND:
  14. # Use, duplication or disclosure by the Government is subject to restrictions
  15. # as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  16. # and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  17. # successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  18. # rights reserved under the Copyright Laws of the United States.
  19. #
  20. # $Id: sdr.cgi,v 1.18 1997/06/19 22:26:39 shotes Exp $
  21.  
  22. require "/usr/OnRamp/lib/OnRamp.pm";
  23.  
  24. use POSIX;
  25.  
  26. $myname = "sdr.cgi";
  27. $list_script = "Apps.sdpd.cgi";
  28.  
  29. $file_dir = "$document_root/apps/sdpd-send";
  30.  
  31. $exp_date = "12-Dec-98";
  32.  
  33. @months = ('Jan','Feb','Mar','Apr','May','Jun',
  34.       'Jul','Aug','Sep','Oct','Nov','Dec');
  35. @days = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
  36.  
  37. if ($ARGV[0]) { 
  38.     $edit_file = $ARGV[0];
  39.     $fld{'mode'} = "e";
  40. } else { $fld{'mode'} = "a"; }
  41.  
  42. &get_cookies;
  43. &get_fields;
  44.  
  45. if ($fld{'get_id'}) {            # being called via "post" from sd-list.cgi
  46.     $new_id = time;
  47.  
  48.     $fld{'sdpd_email'} = $fld{'sdpd_email'};
  49.     if($fld{'sdpd_name'} ne "") { 
  50.         $fld{'sdpd_email'} .= " ($fld{'sdpd_name'})"; 
  51.     }
  52.     $fld{'sdpd_phone'} = $fld{'sdpd_phone'};
  53.  
  54.     $cookie_header = "Content-type: text/html\n"
  55.      . "Set-Cookie: sdpd_id=$new_id; expires=$exp_date; path=/\n"
  56.      . "Set-Cookie: sdpd_phone=$fld{'sdpd_phone'}; expires=$exp_date; path=/\n"
  57.      . "Set-Cookie: sdpd_email=$fld{'sdpd_email'}; expires=$exp_date; path=/\n\n";
  58.  
  59.     $set_cookie = 1;
  60. }
  61.  
  62. &set_timezone;
  63.  
  64. if ($edit_file) { &get_edit_values; }
  65. else { &get_initial_values; }
  66.  
  67. if ($fld{'submit'} eq 'Submit Announcement') {
  68.     $fld{'session_name'} =~ s/^\s+//g;
  69.     $fld{'session_name'} =~ s/\s+$//g;
  70.     if (!&form_validation) { 
  71.         &create_file;
  72.         $fld{'session_name'} =~ s/ /__/g;
  73.     $list_script .= "?$fld{'mode'}+$fld{'session_name'}";
  74.  
  75.     print "Content-type: text/html\n$update_cookie\n";
  76.         print "<HTML><HEAD>";
  77.         print "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0; URL=$list_script\">";
  78.         print "</HEAD><BODY></BODY></HTML>";
  79.  
  80.     exit 0;
  81.     }
  82.     %val = %fld;
  83. }
  84.  
  85. &generic;
  86.  
  87. sub get_cookies {
  88.     local($a, $b);
  89.     undef %cookie;
  90.     foreach (split(/; /, $ENV{HTTP_COOKIE})) {
  91.         ($a, $b) = split(/=/, $_);
  92.         $a =~ s/\s//g;
  93.         $cookie{$a} = $b;
  94.     }
  95. }
  96.  
  97. sub form_validation {
  98.     if ($fld{'session_name'} eq "") {
  99.         $error = "Session name required."; 
  100.         return 1;
  101.     } elsif ($fld{'address'} eq "") {
  102.         $error = "Address required.";
  103.         return 1;
  104.     } elsif (check_ipaddr($fld{'address'})) {
  105.         $error = "Invalid IP address in \"Address\" field.";
  106.         return 1;
  107.     } 
  108.  
  109.     if ($fld{'audio_check'}) {
  110.         if (($error = &check_port($fld{'audio_port'})) ne "") { return 1; }
  111.     } elsif ($fld{'video_check'}) {
  112.         if (($error = &check_port($fld{'video_port'})) ne "") { return 1; }
  113.     } elsif ($fld{'white_check'}) {
  114.         if (($error = &check_port($fld{'white_port'})) ne "") { return 1; }
  115.     } elsif ($fld{'text_check'}) {
  116.         if (($error = &check_port($fld{'text_port'})) ne "") { return 1; }
  117.     }
  118.  
  119.     if ($fld{'email'} eq "") {
  120.         $error = "E-mail address required.";
  121.         return 1;
  122.     } elsif ($fld{'phone'} eq "") {
  123.         $error = "Telephone number required.";
  124.         return 1;
  125.     }
  126. }
  127.  
  128. sub check_port {
  129.     if ($_[0] =~ /[^\d]/) { return "Port numbers must be integers."; }
  130.     elsif ($_[0] < 1024) { return "Port numbers must be more than 1023."; }
  131.     elsif ($_[0] > 65536) { return "Port numbers must be less tnan 65536."; }
  132.     "";
  133. }
  134.     
  135. sub create_file {
  136.  
  137.     if ($edit_file ne "") { $file = $edit_file; }
  138.     elsif ($fld{'edit_file'} ne "") { $file = $fld{'edit_file'}; }
  139.     else {
  140.         $file = tmpnam(0);
  141.         $file =~ /\/([^\/]*)$/;
  142.         $file = $file_dir . "/" . $1;
  143.     }
  144.  
  145.     foreach (keys(%months)) {
  146.         if ($months{$_} eq $cur_month) { $cur_month_num = $_; }
  147.     }
  148.     
  149.     ($s_hour, $s_min) = split(/:/,$fld{'time'});        
  150.     ($s_wday_nm, $s_mon_nm, $s_mday) = split(/\s+/,$fld{'date'});
  151.  
  152.     for ($i=0;$i<=$#months;$i++) {
  153.         if ($months[$i] eq $s_mon_nm) { $s_mon = $i; }
  154.     }
  155.  
  156.     if ($month_num < $cur_month_num) { $s_year = $c_year + 1; }
  157.     else { $s_year = $c_year; }
  158.  
  159.     $start_time = mktime(0,$s_min,$s_hour,$s_mday,$s_mon,$s_year,0,0,-1);
  160.     $start_time += 2208988800;
  161.  
  162.     if ($fld{'duration'} =~ /minutes/) { $dur_secs = 30 * 60; }
  163.     elsif ($fld{'duration'} =~ /(\d+) hour/) { $dur_secs = 3600 * $1; }
  164.     else { $dur_secs = 24 * 3600; }
  165.  
  166.     $rep_secs = 0;
  167.     if ($fld{'active'} ne "once") {    
  168.         if ($fld{'repeat'} =~ /(\d+) hour/) { $rep_secs = 3600 * $1; }
  169.         elsif ($fld{'repeat'} =~ /(\d+) day/) { $rep_secs = 24 * 3600 * $1; }
  170.         else { $fld{'repeat'} =~ /(\d+) week/; $rep_secs = 7 * 24 * 3600 * $1; }    
  171.  
  172.         if ($fld{'active'} eq 'daily') { $repeat_time = 24 * 3600; }
  173.         else { $repeat_time = 7 * 24 * 3600; }
  174.     }
  175.  
  176.     $finish_time = $start_time + $dur_secs + $rep_secs;
  177.                     
  178.     %ttl = ('site','15','region','63','world','127');
  179.  
  180.     if ($new_id) { $file_id = $new_id; }
  181.     else { $file_id = $cookie{'sdpd_id'}; }
  182.  
  183.     open(OUT,"> $file");
  184.  
  185.     print OUT qq|# $file_id\n#\n|;
  186.  
  187.     print OUT qq|vers2\n|;
  188.     print OUT qq|v=0\n|;
  189.  
  190.     if ($fld{'mode'} eq "a") { 
  191.     open(IN, "/usr/bin/whoami |");
  192.     $fld{'username'} = <IN>; chop($fld{'username'});
  193.     close(IN);
  194.         $fld{'session_id'} = time + 2208988800;
  195.         $fld{'version'} = $fld{'session_id'};
  196.  
  197.     open(IN, "/usr/OnRamp/bin/htnetwork |");
  198.     $my_line = <IN>;
  199.     close(IN);
  200.         $fld{'my_ip'} = (split(/:/,$my_line))[3];
  201.  
  202. #       @addrs = (gethostbyname($ENV{SERVER_NAME}))[4];
  203. #       $fld{'my_ip'} = join('.',unpack('C4', $addrs[0]));
  204.     }
  205.  
  206.     print OUT qq|o=$fld{'username'} $fld{'session_id'} $fld{'version'} IN IP4 $fld{'my_ip'}\n|;
  207.     
  208.     print OUT qq|s=$fld{'session_name'}\n|;
  209.  
  210.     $fld{'description'} =~ s/\r\n/ /g;
  211.     print OUT qq|i=$fld{'description'}\n|;
  212.     
  213.     if ($fld{'uri'}) { print OUT qq|u=$fld{'uri'}\n|; }
  214.     
  215.     print OUT qq|e=$fld{'email'}\n|;
  216.     print OUT qq|p=$fld{'phone'}\n|;
  217.  
  218.     print OUT qq|c=IN IP4 $fld{'address'}/$ttl{$fld{'ttl'}}\n|;
  219.  
  220.     print OUT qq|t=$start_time $finish_time\n|;
  221.  
  222.     if ($fld{'active'} ne "once") {
  223.         print OUT qq|r=$repeat_time $dur_secs 0\n|;
  224.     }
  225.  
  226.     if ($fld{'audio_check'}) {
  227.         print OUT qq|m=audio $fld{'audio_port'} $fld{'audio_protocol'}|,
  228.                   qq| $fld{'audio_format'}\n|;
  229.         if ($fld{'audio_recv'}) { print OUT qq|a=recvonly\n|; }    
  230.     }
  231.     if ($fld{'video_check'}) {
  232.         print OUT qq|m=video $fld{'video_port'} $fld{'video_protocol'}|,
  233.                   qq| $fld{'video_format'}\n|;
  234.         if ($fld{'video_recv'}) { print OUT qq|a=recvonly\n|; } 
  235.     }
  236.     if ($fld{'white_check'}) {
  237.         print OUT qq|m=white $fld{'white_port'} $fld{'white_protocol'}|,
  238.                   qq| $fld{'white_format'}\n|;
  239.         if ($fld{'white_recv'}) { print OUT qq|a=recvonly\n|; } 
  240.     }
  241.     if ($fld{'text_check'}) {
  242.         print OUT qq|m=text $fld{'text_port'} $fld{'text_protocol'}|,
  243.                   qq| $fld{'text_format'}\n|;
  244.         if ($fld{'text_recv'}) { print OUT qq|a=recvonly\n|; } 
  245.     }
  246.  
  247.     close(OUT);
  248.  
  249.     if ($fld{'email'} ne $cookie{'sdpd_email'}) {
  250.         $update_cookie = "Set-Cookie: sdpd_email=$fld{'email'};"
  251.                        . " expires=$exp_date; path=/\n"; 
  252.     }
  253.     if ($fld{'phone'} ne $cookie{'sdpd_phone'}) {
  254.         $update_cookie .= "Set-Cookie: sdpd_phone=$fld{'phone'};"
  255.                         . " expires=$exp_date; path=/\n"; 
  256.     }
  257. }
  258.     
  259. sub get_edit_values {
  260.  
  261.     open(IN, "< $edit_file");
  262.     
  263.     while(<IN>) {
  264.         @items = split(/=/);
  265.         chop($items[1]);
  266.  
  267.         if ($items[0] eq "o") { 
  268.         
  269.             ($fld{'username'}, $fld{'session_id'}, $fld{'version'}, 
  270.                 $dum, $dum, $fld{'my_ip'}) = split(/\s+/, $items[1]);
  271.     
  272.         } elsif ($items[0] eq "s") {
  273.             
  274.             $val{'session_name'} = $items[1];
  275.  
  276.         } elsif ($items[0] eq "i") {
  277.     
  278.             @words = split(/\s+/,$items[1]);
  279.  
  280.             $val{'description'} = shift(@words);
  281.             $len = length($val{'description'});
  282.  
  283.             while ($word = shift(@words)) {
  284.                 $len += length($word) + 1;
  285.  
  286.                 if ($len > 40) {
  287.                     $val{'description'} .= "\n$word";
  288.                     $len = length($word);
  289.                 } else { $val{'description'} .= " $word"; }
  290.             }
  291.  
  292.  
  293.         } elsif ($items[0] eq "u") {
  294.  
  295.             $val{'uri'} = $items[1];
  296.  
  297.         } elsif ($items[0] eq "e") {
  298.  
  299.             $val{'email'} = $items[1];
  300.  
  301.         } elsif ($items[0] eq "p") {
  302.  
  303.             $val{'phone'} = $items[1];
  304.  
  305.         } elsif ($items[0] eq "c") {
  306.  
  307.             ($val{'address'}, $ttl) = split(/\//, (split(/\s+/, $items[1]))[2]);
  308.             if    ($ttl == 15) { $val{'ttl'} = "site"; }
  309.             elsif ($ttl == 63) { $val{'ttl'} = "region"; }
  310.             else               { $val{'ttl'} = "world"; }
  311.  
  312.         } elsif ($items[0] eq "m") {
  313.  
  314.             ($format, $a, $b, $c) = split(/\s+/, $items[1]);
  315.             $val{$format . "_check"} = "on";
  316.             $val{$format . "_port"} = $a;
  317.             $val{$format . "_protocol"} = $b;
  318.             $val{$format . "_format"} = $c;
  319.  
  320.         } elsif ($items[0] eq "a") {
  321.  
  322.             $val{$format . "_recv"} = "on";
  323.  
  324.         } elsif ($items[0] eq "t") {
  325.  
  326.             ($start, $finish) = split(/\s+/, $items[1]);
  327.             $start -= 2208988800;
  328.             $finish -= 2208988800;
  329.             $time_diff = $finish - $start;
  330.  
  331.             ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($start);
  332.  
  333.             if ($min == 0) { $min = "00"; }
  334.             
  335.             $val{'date'} = "$days[$wday] $months[$mon] $mday";    
  336.             $val{'time'} = $hour . ":" . $min;
  337.         
  338.         } elsif ($items[0] eq "r") {
  339.  
  340.             ($rep_int, $act_dur, $dum) = split(/\s+/, $items[1]);
  341.             
  342.             if    ($act_dur < 3600) { $val{'duration'} = "30 minutes"; }
  343.             elsif ($act_dur < 7200) { $val{'duration'} = "1 hour"; }
  344.             elsif ($act_dur < 3600 * 11) { 
  345.                 $num_hours = $act_dur / 3600;
  346.                 $val{'duration'} = "$num_hours hours";
  347.             }
  348.             else { $val{'duration'} = "1 day"; }
  349.  
  350.             if ($rep_int == 3600 * 24) { $val{'active'} = "daily"; }
  351.             else { $val{'active'} = "weekly"; }
  352.  
  353.         }
  354.  
  355.     }
  356.  
  357.     close(IN);
  358.  
  359.     if ($rep_int) {
  360.  
  361.         $repeat = $time_diff - $act_dur;
  362.  
  363.         if ($repeat < 24 * 3600) { $type = "hour"; $num = $repeat / 3600; }
  364.         elsif ($repeat < 7 * 24 * 3600) { $type = "day";  $num = $repeat / (24 * 3600); }
  365.         else { $type = "week"; $num = $repeat / (7 * 24 * 3600); }
  366.  
  367.         if ($num != 1) { $plural = "s"; }
  368.  
  369.         $val{'repeat'} = "$num $type$plural";
  370.  
  371.     } else {
  372.  
  373.         $act_dur = $time_diff;
  374.         if    ($act_dur < 3600) { $val{'duration'} = "30 minutes"; }
  375.         elsif ($act_dur < 7200) { $val{'duration'} = "1 hour"; }
  376.         elsif ($act_dur < 3600 * 11) {
  377.             $num_hours = $act_dur / 3600;
  378.             $val{'duration'} = "$num_hours hours";
  379.         }
  380.         else { $val{'duration'} = "1 day"; }
  381.  
  382.     }
  383.  
  384.     $val{'edit_file'} = $edit_file;
  385. }        
  386.             
  387.         
  388. sub set_timezone {
  389.  
  390.     if (-e "/etc/TIMEZONE") { 
  391.         open(IN,"< /etc/TIMEZONE");    
  392.         while(<IN>) {
  393.             @items = split(/=/);
  394.             if ($items[0] eq "TZ") { 
  395.                 chop $items[1]; 
  396.                 $ENV{'TZ'} = $items[1]; 
  397.             }
  398.         }
  399.         close(IN);
  400.     }
  401. }
  402.  
  403. sub get_initial_values {
  404.  
  405.     ($c_sec, $c_min, $c_hour, $c_mday, $c_mon, $c_year, $c_wday, $c_yday,
  406.         $c_isdst) = localtime(time);
  407.  
  408.     $val{'time'} = $c_hour . ":00";
  409.  
  410.     if ($c_mon < 2) { $leap_check = $c_year; }
  411.     else { $leap_check = $c_year + 1; }
  412.  
  413.     $leap_check = 0;
  414.     if ( ($leap_check % 4) == 0 && ($leap_check % 100) != 0 ) { $leap_year = 1; }
  415.     if ($leap_year) { $feb_days = 29; }
  416.     else { $feb_days = 28; }
  417.  
  418.     $val{'date'} = "$days[$c_wday] $months[$c_mon] $c_mday";
  419.  
  420.     srand(time);
  421.  
  422.     $val{'audio_port'} = int(rand(65535-5001)) + 5001;
  423.     $val{'video_port'} = int(rand(65535-5001)) + 5001;
  424.     $val{'white_port'} = int(rand(65535-5001)) + 5001;
  425.     $val{'text_port' } = int(rand(65535-5001)) + 5001;
  426.  
  427.     $ip_3 = int(rand(253)) + 1;
  428.     $ip_4 = int(rand(253)) + 1;
  429.  
  430.     $val{'address'} = "224.2." . $ip_3 . "." . $ip_4;
  431.  
  432.     if ($fld{'get_id'}) {
  433.         $val{'phone'} = $fld{'sdpd_phone'};
  434.         $val{'email'} = $fld{'sdpd_email'};
  435.     } else {
  436.         $val{'phone'} = $cookie{'sdpd_phone'};
  437.         $val{'email'} = $cookie{'sdpd_email'};
  438.     }
  439.  
  440.     $val{'audio_check'} = "on";
  441. }
  442.  
  443. sub generic {
  444.  
  445.     if ($set_cookie) { print $cookie_header; }
  446.     else { print qq|Content-type: text/html\n\n|; }
  447.     print qq|<html><head><title>Session Directory Manager</title>\n|;
  448.  
  449.     &print_javascript;
  450.  
  451.     print qq|</head>\n|;
  452.  
  453.     print "<body bgcolor=#CCC28F background=\"/images/sdr-bg.gif\"\n";
  454.     print "link=#27002B vlink=#00582A text=#800019>\n";
  455.  
  456.     print "<table width=100%>\n";
  457.     print "<tr><th align=left><h1>Create Announcement</h1></th>\n";
  458.     print "<th align=right>\n";
  459.     print "<a href=\"/apps/sdr_hlp.cgi\"><img border=0 height=65 width=30 src=\"/images/help.gif\"></a>\n";
  460.     print "  ";
  461.     print "<a href=\"/newsplash.shtml\"><img border=0 height=55 width=57 src=\"/apps/home.gif\"></a>\n";
  462.         print "  ";
  463.         print "<a href=\"/apps/Apps.shtml\"><img border=0 height=55 width=57 src=\"/apps/back.gif\"></a>\n";
  464.     print "</tr></table>\n";
  465.  
  466.     print qq|<map name="time_map">\n|; 
  467.     print qq|<area shape="rect" coords="0,0,15,15" href="JavaScript:TimeUp()">|;
  468.     print qq|<area shape="rect" coords="0,15,15,30" href="JavaScript:TimeDown()">|;
  469.     print qq|</map>|;
  470.  
  471.     print qq|<map name="date_map">\n|;
  472.     print qq|<area shape="rect" coords="0,0,15,15" href="JavaScript:DateUp()">|;
  473.     print qq|<area shape="rect" coords="0,15,15,30" href="JavaScript:DateDown()">|;
  474.     print qq|</map>|;
  475.  
  476.     print qq|<center>\n|;
  477.  
  478.     print qq|</center><i>$message</i><center>\n|;
  479.     if ($error) {print qq|</center><font color=#FF0000>Error: $error</font><center>\n|; }
  480.  
  481.     print qq|<form name="page1" method=post action=$myname>\n|;
  482.  
  483.     print qq|<input type="hidden" name="mode" value=$fld{'mode'}>\n|;
  484.  
  485.     if ($val{'edit_file'}) {
  486.         print qq|<input type="hidden" name="session_id" value=$fld{'session_id'}>\n|;
  487.         print qq|<input type="hidden" name="version" value=$fld{'version'}>\n|;
  488.         print qq|<input type="hidden" name="my_ip" value=$fld{'my_ip'}>\n|;
  489.         print qq|<input type="hidden" name="username" value=$fld{'username'}>\n|;
  490.         print qq|<input type="hidden" name="edit_file" value=$val{'edit_file'}>\n|; 
  491.     }
  492.  
  493.     print qq|<input type="hidden" name="feb_days" value="$feb_days">\n|;
  494.  
  495.     print qq|<table width=600>\n|;
  496.  
  497.     print qq|<tr><th align=left>Session Name:</th><td align=left>\n|, 
  498.           &mtext("session_name", $val{'session_name'}, 30), "</td></tr>\n";
  499.  
  500.     print qq|<tr><th align=left valign=top>Description:</th><td align=left>\n|,
  501.           qq|<textarea name="description" rows=5 cols=40>$val{'description'}|,
  502.           qq|</textarea></td></tr>|;
  503.  
  504.     print qq|<tr><th align=left>URI:</th><td align=left>\n|,
  505.           &text("uri", $val{'uri'}, 30), "</td></tr>\n";
  506.         
  507.     print qq|<tr align=left><th>Address:</th><td align=left>\n|, 
  508.           &text("address", $val{'address'}, 30), "</td></tr>\n";
  509.  
  510.     print qq|<tr><th align=left>Scope (ttl):</th><td align=left>\n|,
  511.           &select("ttl",$val{'ttl'},"site","region","world"), "</td></tr>\n";
  512.  
  513.     print qq|</table><hr><table width=600>\n|;
  514.  
  515.     print qq|<tr><th align=left colspan=2>Media</th><th align=left>Recvonly</th>|,
  516.           qq|<th align=left>Protocol</th><th align=left>Format</th><th align=left>|,
  517.           qq|Port</th></tr>\n|;
  518.  
  519.     print qq|<tr><td>|, &check("audio_check", $val{'audio_check'}), 
  520.           qq|</td><th align=left>Audio</th>|;
  521.     print qq|<td>|, &check("audio_recv", $val{'audio_recv'}), qq|</td>|;
  522.     print qq|<td>|, &select("audio_protocol", $val{'audio_protocol'},"vat","rtp"), 
  523.           qq|</td>\n|;
  524.     print qq|<td>|, &select("audio_format", $val{'audio_format'},"pcm","dvi","gsm","lpc4"), 
  525.           qq|</td>\n|;
  526.     print qq|<td>|, &text("audio_port", $val{'audio_port'}, 6), qq|</td>\n|; 
  527.     print qq|</tr>|;
  528.     
  529.     print qq|<tr><td>|, &check("video_check", $val{'video_check'}), 
  530.           qq|</td><th align=left>Video</th>|;
  531.     print qq|<td>|, &check("video_recv", $val{'video_recv'}), qq|</td>|;
  532.     print qq|<td>|, &select("video_protocol", $val{'video_protocol'},"rtp"), qq|</td>\n|;
  533.     print qq|<td>|, &select("video_format", $val{'video_format'},"nv","h261","jpg","ivs"), 
  534.           qq|</td>\n|;
  535.     print qq|<td>|, &text("video_port", $val{'video_port'}, 6), qq|</td>\n|; 
  536.     print qq|</tr>|;
  537.     
  538.     print qq|<tr><td>|, &check("white_check", $val{'white_check'}), 
  539.           qq|</td><th align=left>Whiteboard</th>|;
  540.     print qq|<td>|, &check("white_recv", $val{'white_recv'}), qq|</td>|;
  541.     print qq|<td>|, &select("white_protocol", $val{'white_protocol'},"udp"), qq|</td>\n|;
  542.     print qq|<td>|, &select("white_format", $val{'white_format'},"wb","nt"), qq|</td>\n|;
  543.     print qq|<td>|, &text("white_port", $val{'white_port'}, 6), qq|</td>\n|; 
  544.     print qq|</tr>|;
  545.     
  546.     print qq|<tr><td>|, &check("text_check", $val{'text_check'}), qq|</td><th align=left>Text</th>|;
  547.     print qq|<td>|, &check("text_recv", $val{'text_recv'}), qq|</td>|;
  548.     print qq|<td>|, &select("text_protocol", $val{'text_protocol'},"udp"), qq|</td>\n|;
  549.     print qq|<td>|, &select("text_format", $val{'text_format'},"nt","mumble"), qq|</td>\n|;
  550.     print qq|<td>|, &text("text_port", $val{'text_port'}, 6), qq|</td>\n|; 
  551.     print qq|</tr>|;
  552.     
  553.     print qq|</table><hr><table width=600>|;
  554.  
  555.     print qq|<tr><th align=left>Broadcast</th><td align=left>\n|;
  556.     print &select("active",$val{'active'},"once","daily","weekly"), "</td></tr>\n";
  557.     print "<tr><th align=left>From:</th><td align=left>", 
  558.           qq|<input type="text" name="date" value="$val{'date'}" size=10 onFocus="this.blur();">\n|,
  559.           qq|<img src="/images/arrows.gif" border=2 align="top" usemap="#date_map">\n|,
  560.           qq|<input type="text" name="time" value="$val{'time'}" size=5 onFocus="this.blur();">\n|, 
  561.           qq|<img src="/images/arrows.gif" border=2 align="top" usemap="#time_map">\n|,
  562.           qq| for |,    
  563.           &select("duration",$val{'duration'},"30 minutes","1 hour","2 hours","3 hours",
  564.           "4 hours","5 hours","6 hours","7 hours","8 hours","9 hours",
  565.           "10 hours","1 day"), "</td></tr>\n";
  566.     print qq|<tr><th align=left>Repeat for:</th><td align=left>\n|,
  567.           &select("repeat",$val{'repeat'},"1 hour","2 hours","3 hours","4 hours",
  568.           "5 hours","6 hours","7 hours","8 hours","9 hours","10 hours",
  569.           "1 day","2 days","3 days","4 days","5 days","1 week","2 weeks",
  570.           "3 weeks","4 weeks"),
  571.           qq|</td></tr>\n|;
  572.  
  573.     print qq|</table><hr><table width=600>\n|;
  574.  
  575.     print qq|<tr><th align=left>email:</th><td>|,
  576.           qq|<input type=text name="email" value="$val{'email'}" size=30></td></tr>\n|;
  577.  
  578.     print qq|<tr><th align=left>phone:</th><td>|,
  579.           qq|<input type=text name="phone" value="$val{'phone'}" size=30></td></tr>\n|;
  580.  
  581.     print qq|</table><table width=600>\n|;
  582.     
  583.     print qq|<tr><td><input name="submit" type="submit" value="Submit Announcement"></td></tr>\n|;
  584.  
  585.     print qq|</table>\n|;
  586.  
  587.     print qq|</center></form></body></html>\n|;
  588.  
  589. }
  590.  
  591. sub mtext { 
  592.     local($ret) = "<input name=\"$_[0]\" value=\"$_[1]\"";
  593.     if ($_[2]) { $ret .= " size=$_[2]"; }
  594.     $ret .= ">";
  595. }
  596.  
  597. sub check {
  598.     local($ret) = qq|<input type=checkbox name=$_[0]|;
  599.     if ($_[1]) { $ret .= " checked"; }
  600.     $ret .= ">";
  601. }
  602.  
  603. sub print_javascript {
  604.  
  605. print <<EOJS
  606.  
  607. <script language="JavaScript">
  608. <!--
  609.  
  610. function TimeUp() 
  611. {
  612.     var hours, minutes;
  613.     form = document.page1;
  614.     hours = form.time.value.substring(0,2);
  615.     minutes = form.time.value.substring(3,5);
  616.     if (minutes == "30") {
  617.         hours = eval(hours + "+1");
  618.         if (hours < 10) { hours = "0" + hours; }
  619.         if (hours > 23) { hours = "00"; }
  620.         minutes = "00";
  621.     } else {
  622.         minutes = "30";
  623.     }
  624.     form.time.value = hours + ":" + minutes; 
  625. }
  626.  
  627. function TimeDown()
  628. {
  629.     var hours, minutes;
  630.     form = document.page1;
  631.     hours = form.time.value.substring(0,2);
  632.     minutes = form.time.value.substring(3,5);
  633.     if (minutes == "30") {
  634.         minutes = "00";
  635.     } else {
  636.         hours = eval(hours + "-1");
  637.         if (hours < 0) { hours = "23"; }
  638.         if (hours < 10) { hours = "0" + hours; }
  639.         minutes = "30";
  640.     }
  641.     form.time.value = hours + ":" + minutes;       
  642. }
  643.  
  644. function DateUp()
  645. {
  646.     days_in_month = new createArray(12);
  647.     days_of_week = new createArray(7);
  648.     mon_yr = new createArray(12);
  649.     var j, week_day, week_day_nm, num_day, month;
  650.     var add_month;
  651.  
  652.     form = document.page1;
  653.  
  654.     mon_yr[0] = "Jan"; mon_yr[1] = "Feb"; mon_yr[2] = "Mar"; mon_yr[3] = "Apr";
  655.     mon_yr[4] = "May"; mon_yr[5] = "Jun"; mon_yr[6] = "Jul"; mon_yr[7] = "Aug";
  656.     mon_yr[8] = "Sep"; mon_yr[9] = "Oct"; mon_yr[10] = "Nov"; mon_yr[11] = "Dec";
  657.     
  658.     for (j=0; j<12; j++) { days_in_month[j] = 31; }
  659.     days_in_month[1] = form.feb_days.value;
  660.     days_in_month[3] = 30;
  661.     days_in_month[5] = 30;
  662.     days_in_month[8] = 30;
  663.     days_in_month[10] = 30;
  664.  
  665.     days_of_week[0] = "Sun"; days_of_week[1] = "Mon"; days_of_week[2] = "Tue"; days_of_week[3] = "Wed";
  666.     days_of_week[4] = "Thu"; days_of_week[5] = "Fri"; days_of_week[6] = "Sat";
  667.  
  668.     week_day = form.date.value.substring(0,3);
  669.     num_day = form.date.value.substring(8,10);
  670.     month = form.date.value.substring(4,7);
  671.  
  672.     for (j=0; j<7; j++) { 
  673.         if (week_day == days_of_week[j]) { week_day_nm = j; }
  674.     }
  675.     week_day_nm = eval(week_day_nm + "+1");
  676.     if (week_day_nm > 6) { week_day = "Sun"; }
  677.     else { week_day = days_of_week[week_day_nm]; }
  678.  
  679.     for (j=0; j<12; j++) {
  680.         if (month == mon_yr[j]) { month_nm = j; }
  681.     }
  682.     add_month = 0;
  683.     if (num_day == days_in_month[month_nm]) {
  684.         num_day = 1;
  685.         add_month = 1;
  686.     } else { num_day = eval(num_day + "+1"); }
  687.     if (add_month == 1) {
  688.         month_nm = eval(month_nm + "+1");
  689.         if (month_nm == 12) { month_nm = 1; }
  690.         month = mon_yr[month_nm];
  691.     }
  692.  
  693.     form.date.value = week_day + " " + month + " " + num_day;
  694.  
  695. function DateDown()
  696. {
  697.     days_in_month = new createArray(12);
  698.     days_of_week = new createArray(7);
  699.     mon_yr = new createArray(12);
  700.     var j, week_day, week_day_nm, num_day, month;
  701.  
  702.     form = document.page1;
  703.     mon_yr[0] = "Jan"; mon_yr[1] = "Feb"; mon_yr[2] = "Mar"; mon_yr[3] = "Apr";
  704.     mon_yr[4] = "May"; mon_yr[5] = "Jun"; mon_yr[6] = "Jul"; mon_yr[7] = "Aug";
  705.     mon_yr[8] = "Sep"; mon_yr[9] = "Oct"; mon_yr[10] = "Nov"; mon_yr[11] = "Dec";
  706.  
  707.     for (j=0; j<12; j++) { days_in_month[j] = 31; }
  708.     days_in_month[1] = form.feb_days.value;
  709.     days_in_month[3] = 30;
  710.     days_in_month[5] = 30;
  711.     days_in_month[8] = 30;
  712.     days_in_month[10] = 30;
  713.  
  714.     days_of_week[0] = "Sun"; days_of_week[1] = "Mon"; days_of_week[2] = "Tue"; days_of_week[3] = "Wed";
  715.     days_of_week[4] = "Thu"; days_of_week[5] = "Fri"; days_of_week[6] = "Sat";
  716.  
  717.     week_day = form.date.value.substring(0,3);
  718.     num_day = form.date.value.substring(8,10);
  719.     month = form.date.value.substring(4,7);
  720.     for (j=0; j<7; j++) {
  721.         if (week_day == days_of_week[j]) { week_day_nm = j; }
  722.     }
  723.  
  724.     week_day_nm = eval(week_day_nm + "-1");
  725.     if (week_day_nm < 0) { week_day = "Sat"; }
  726.     else { week_day = days_of_week[week_day_nm]; }
  727.     for (j=0; j<12; j++) {
  728.         if (month == mon_yr[j]) { month_nm = j; }
  729.     }
  730.  
  731.     num_day = eval(num_day + "-1");
  732.     if (num_day < 1) {
  733.         month_nm = eval(month_nm + "-1");
  734.         if (month_nm < 0) { month_nm = 11; }
  735.         num_day = days_in_month[month_nm];
  736.         month = mon_yr[month_nm];
  737.     }
  738.     
  739.     form.date.value = week_day + " " + month + " " + num_day;
  740. }
  741.  
  742. function createArray(num) {
  743.     this.length = 12;
  744.     for (var j=0; j < num; j++) { this[j] = ""; }
  745. }
  746.     
  747.  
  748. // -->
  749. </script>
  750.  
  751. EOJS
  752.  
  753. }
  754.